package com.hzit.cart.api.factory;

import com.hzit.cart.api.RemoteCartService;
import com.hzit.cart.api.domain.Address;
import com.hzit.cart.api.domain.Order;
import com.hzit.cart.api.domain.OrderItem;
import com.hzit.cart.api.domain.PayLog;
import com.hzit.cart.api.model.ItemVo;
import com.hzit.manager.api.RemoteManagerService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Component
public class RemoteCartFallback implements FallbackFactory<RemoteCartService> {
	@Override
	public RemoteCartService create(Throwable cause) {
		return new RemoteCartService() {
			@Override
			public R<List<Address>> addressList() {
				return R.fail("查询登录用户地址列表失败：" + cause.getMessage());
			}

			@Override
			public R<Map<String, List<ItemVo>>> findCart() {
				return R.fail("查询登录购物车列表失败：" + cause.getMessage());
			}

			@Override
			public R saveOrder(Order order) {
				return R.fail("保存订单失败：" + cause.getMessage());
			}

			@Override
			public R saveOrderItem(OrderItem orderItem) {
				return R.fail("保存订单项失败：" + cause.getMessage());
			}

			@Override
			public R savePayLog(PayLog payLog) {
				return R.fail("保存支付日志失败：" + cause.getMessage());
			}

			@Override
			public R<List<Order>> getOrderList(String login) {
				return R.fail("查询订单列表失败：" + cause.getMessage());
			}

			@Override
			public R<PayLog> findPayLog(String out_trade_no) {
				return R.fail("查询支付日志失败：" + cause.getMessage());
			}

			@Override
			public R updatePayLog(PayLog payLog) {
				return R.fail("修改支付日志失败：" + cause.getMessage());
			}

			@Override
			public R updateOrder(String id, String status) {
				return R.fail("修改订单失败：" + cause.getMessage());
			}
		};
	}
}
